<template>
    <div class="gallery-container" @click.stop="$emit('closeGallery')">
        <div class="img-wraper">
            <swiper :options="swiperOption"  ref="mySwiper">
                <swiper-slide v-for="(item, index) of imgDatas" :key="index">
                    <img class="swiper-img" :src="item" alt="">
                </swiper-slide>
                <div class="swiper-pagination"  slot="pagination"></div>
            </swiper>
        </div>
    </div>
</template>

<script>
export default {
    name: 'Gallery',
    props: {
        imgDatas: Array
    },
    data(){
        return{
            swiperOption: {
                pagination : '.swiper-pagination',
                paginationType: 'fraction',
                observer: true,// 元素改变初始化
                observeParents: true, // 父元素改变组件初始化
            }
        }
    }
}
</script>

<style lang="stylus" scoped>
    div{
        display: flex;
    }

    .gallery-container >>> .swiper-container{
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .gallery-container >>> .swiper-slide {
        flex-direction: column;
        justify-content: center;
    }

    .gallery-container{
        display: flex;
        flex-direction: column;
        justify-content: center;
        position: fixed;
        z-index: 99;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: #000;
    }

    .gallery-container .img-wraper{
        width: 100%;
        height: 0;
        padding-bottom: 100%;
    }

    .gallery-container .swiper-img{
        width: 100%;
    }

    .gallery-container .img-wraper .swiper-pagination {
        bottom: .48rem;
        color: #fff;
        justify-content: center;
    }
</style>